﻿create sequence fj_HR2_S
  minvalue 1        --最小值
  nomaxvalue        --不设置最大值
  start with 1      --从1开始计数
  increment by 1    --每次加1个
  nocycle           --一直累加，不循环 
  nocache          --不建缓冲区

create sequence fj_Org2_S
  minvalue 1        --最小值
  nomaxvalue        --不设置最大值
  start with 1      --从1开始计数
  increment by 1    --每次加1个
  nocycle           --一直累加，不循环 
  nocache          --不建缓冲区

-- Creating table 'fj_HR2'
CREATE TABLE padmin.fj_HR2 (
    ID NUMBER(38,0)  NOT NULL PRIMARY KEY,
    PersonId nvarchar2(50)  NULL,
    CName nvarchar2(10)  NULL,
    PersonCode nvarchar2(30)  NULL,
    Gender int  NULL,
    Birth date  NULL,
    Email nvarchar2(50)  NULL,
    Company nvarchar2(50)  NULL,
    CompanyCode nvarchar2(50)  NULL,
    Dept nvarchar2(50)  NULL,
    DeptCode nvarchar2(50)  NULL,
    ManageWork nvarchar2(50)  NULL,
    SequenceInDept nvarchar2(50)  NULL,
    PositionTypeName nvarchar2(50)  NULL,
    PositionTypeCode nvarchar2(50)  NULL,
    PositionName nvarchar2(50)  NULL,
    PositionCode nvarchar2(50)  NULL,
    PoliticalFaceName nvarchar2(50)  NULL,
    PoliticalFaceCode nvarchar2(50)  NULL,
    EmployeePropName nvarchar2(50)  NULL,
    EmployeePropCode nvarchar2(50)  NULL,
    JobStart date  NULL,
    Status nvarchar2(50)  NULL,
    StatusCode nvarchar2(50)  NULL,
    DiplomaName nvarchar2(50)  NULL,
    DiplomaCode nvarchar2(50)  NULL,
    DeleteStatus int  NULL,
    Unknow1 nvarchar2(50)  NULL,
    QueryStartDate date  NULL,
    QueryEndDate date  NULL,
    O_Index int  NULL,
    O_uid nvarchar2(50)  NULL
);

-- Creating table 'fj_Org2'
CREATE TABLE padmin.fj_Org2 (
    ID NUMBER(32,0) NOT NULL PRIMARY KEY,
    OrgCode nvarchar2(50)  NULL,
    OrgName nvarchar2(50)  NULL,
    OrgName2 nvarchar2(50)  NULL,
    UsedFlag int  NULL,
    ParentOrgCode nvarchar2(50)  NULL,
    OrgType nvarchar2(50)  NULL,
    OrgProType nvarchar2(50)  NULL,
    OrgLevel nvarchar2(50)  NULL,
    OrgRegion nvarchar2(50)  NULL,
    OrgFileName nvarchar2(50)  NULL,
    QueryStartDate date  NULL,
    QueryEndDate date  NULL,
    O_index int  NULL
);



--创建需要分别执行：
CREATE OR REPLACE TRIGGER fj_HR2_primary
BEFORE INSERT ON padmin.fj_HR2 FOR EACH ROW WHEN (new.id is null) 
BEGIN
 	 select padmin.fj_HR2_S.nextval into:new.id from dual;
end;

--创建需要分别执行：
CREATE OR REPLACE TRIGGER fj_Org2_primary
BEFORE INSERT ON padmin.fj_Org2 FOR EACH ROW WHEN (new.id is null) 
BEGIN
 	 select padmin.fj_Org2_S.nextval into:new.id from dual;
end;

--to_date('17-10-2012 10:38:30', 'dd-mm-yyyy hh24:mi:ss')


